<template>
    <div class="app">
        <el-container class="container">
            <el-aside class="app-side" v-bind:style="{ width: isCollapse ? '40px':'280px'}" :class="isCollapse ? 'app-side-collapsed' : 'app-side-expanded'">
                <div class="app-side-logo" v-show="photo">
                    <img src="../assets/image/logs.png" class="headlogo" @click="openPhoto" />
                    <!-- <img src="../assets/whitelogo.png" class="headlogo1" v-show="!photo" /> -->

                </div>
                <div class="app-side-logo1" v-show="!photo">
                    <!-- <img src="../assets/whitelogo.png" class="headlogo" v-show="photo" /> -->
                    <img src="../assets/image/logs.png" class="headlogo1" />

                </div>
                <!-- <div>
                    <el-menu :default-active="defaultActive" router class="el-menu-vertical-demo" @open="handleOpen" :collapse="isCollapse">
                        <template v-for="route in $router.options.routes" v-if="route.children && route.children.length">
                            <template v-for="item in route.children">
                                <el-menu-item :key="route.path + '/' + item.path" :index="item.path">
                                    <i class='el-icon-reading'></i>
                                    <span slot="title">{{ item.name }}</span>
                                </el-menu-item>
                            </template>
                        </template>
                    </el-menu>
                </div> -->
                <el-menu :default-active="defaultActive" style="height: 100%; width:100%" background-color="#545c64" text-color="#fff" active-text-color="#fff" router>
                    <!-- <el-menu-item index="manage"><i class="el-icon-menu"></i>首页</el-menu-item> -->
                    <el-submenu index="2">
                        <template slot="title"><i class="el-icon-document"></i>数据管理</template>
                        <el-menu-item index="userList">用户列表</el-menu-item>
                        <el-menu-item index="shop">商家列表</el-menu-item>
                        <el-menu-item index="food">食品列表</el-menu-item>
                        <el-menu-item index="orderList">订单列表</el-menu-item>
                        <el-menu-item index="adminList">管理员列表</el-menu-item>
                        <el-menu-item index="echarts">图表</el-menu-item>
                    </el-submenu>
                    <el-submenu index="3">
                        <template slot="title"><i class="el-icon-plus"></i>添加数据</template>
                        <el-menu-item index="addShop">添加商铺</el-menu-item>
                        <!-- <el-menu-item index="addGoods">添加商品</el-menu-item> -->
                    </el-submenu>
                    <!-- <el-submenu index="4">
                        <template slot="title"><i class="el-icon-star-on"></i>图表</template>
                        <el-menu-item index="visitor">用户分布</el-menu-item>
                    </el-submenu> -->
                    <!-- <el-submenu index="5">
                        <template slot="title"><i class="el-icon-edit"></i>编辑</template>
                        <el-menu-item index="vueEdit">文本编辑</el-menu-item>
                    </el-submenu>
                    <el-submenu index="6">
                        <template slot="title"><i class="el-icon-setting"></i>设置</template>
                        <el-menu-item index="">管理员设置</el-menu-item>
                    </el-submenu> -->
                    <el-menu-item index="explain">
                        <i class="el-icon-setting"></i>
                        <span slot="title">电子签名</span>
                    </el-menu-item>
                    <el-menu-item index="compontProp">
                        <i class="el-icon-s-promotion"></i>
                        <span slot="title">组件传参</span>
                    </el-menu-item>
                    <el-menu-item index="videos">
                        <i class="el-icon-video-camera-solid"></i>
                        <span slot="title">视频播放</span>
                    </el-menu-item>
                    <el-menu-item index="compareText">
                        <i class="el-icon-folder-opened"></i>
                        <span slot="title">文件对比</span>
                    </el-menu-item>
                    <el-menu-item index="tree">
                        <i class="el-icon-folder-opened"></i>
                        <span slot="title">目录树</span>
                    </el-menu-item>
                    <el-menu-item index="map">
                        <i class="el-icon-folder-opened"></i>
                        <span slot="title">地图</span>
                    </el-menu-item>
                      <el-menu-item index="signature">
                        <i class="el-icon-folder-opened"></i>
                        <span slot="title">h5电子签名</span>
                    </el-menu-item>
                </el-menu>
                <!-- <Sidebar :collapse="isCollapse" :routes="$router.options.routes[1].children" /> -->
            </el-aside>

            <el-container>
                <el-header class="app-header">
                    <div style="width: 50px; cursor: pointer; font-size: 20px;" @click.prevent="toggleSideBar">
                        <i v-show="!isCollapse" class="fa fa-bars navTagerBrn"></i>
                        <i v-show="isCollapse" class="fa fa-bars navTagerBrn"></i>
                    </div>
                    <!-- 我是样例菜单 -->
                    <el-menu default-active="/" router class="fa fa-bars navTagerBrn" mode="horizontal">
                        <!-- <i @click="targetOpen" class=""></i> -->
                        <el-menu-item>小小平台</el-menu-item>
                    </el-menu>
                    <div class="app-header-userinfo">
                        <el-dropdown trigger="hover" :hide-on-click="false">

                            <span class="el-dropdown-link" style="margin-right:15px"  @click="userInfo">
                                {{ username }}
                            </span>
                            <span @click="userInfo">
                                <img class="userShow" src="../assets/image/avatar.png">
                            </span>
                            <span class="right-item" @click="showMsgbox">
                                <i class="fa fa-bell fa-fw"></i>消息
                                <el-badge :value=messageNum class="item"></el-badge>
                            </span>
                            <span  @click="logout">
                                <img class="quitStyle" src='../assets/image/quit.png' />
                            </span>
                            <el-dropdown-menu slot="dropdown" style="cursor:pointer;margin-right:100px">
                                <!-- <el-dropdown-item @click="setClick">设置</el-dropdown-item> -->
                            </el-dropdown-menu>

                        </el-dropdown>
                    </div>
                </el-header>

                <el-main class="app-body">
                    <template>
                        <router-view />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <weixinPhotoDialog ref="weixinPhotoDialog"></weixinPhotoDialog>
        <message ref="message"></message>
    </div>
</template>

<script>
    import logo from '../assets/image/avatar.png'
    import weixinPhotoDialog from './verificationCode/Dialog/weixinPhotoDialog.vue'
    import message from '../components/message.vue'
    import Sidebar from '@/components/Sidebar'
    import UserConfigDetail from '@/view/UserConfigDetail'
    export default {
        name: 'home',
        components: {
            Sidebar,
            weixinPhotoDialog,
            message,
            UserConfigDetail
        },
        data() {
            return {
                messageNum: 1,
                logo: '',
                photo: true,
                username: '',
                isCollapse: false,
                defaultActive: '/',
            }
        },
        methods: {
            userInfo(){
                console.log('2222');
                this.$router.push({
                    name:'UserConfigDetail'
                })
            },
            //消息
            showMsgbox() {
                this.$refs.message.show();
                console.log('111');
                //  this.$refs.weixinPhotoDialog.showData();
            },
            openPhoto() {
                this.$refs.weixinPhotoDialog.showData();
            },
            toggleSideBar() {
                this.isCollapse = !this.isCollapse;
                this.photo = !this.photo;
                // this.$store.commit('openclosenav', !this.$store.state.Nav.isCollapse);
                this.$store.dispatch('updatePageWidth', window.innerWidth);

            },
            logout: function() {
                this.$confirm('确定要退出登录吗', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        closeOnClickModal: false,
                    })
                    .then(() => {
                        sessionStorage.removeItem('user');
                        this.$router.push('/');
                    })
                    .catch(() => {});
            },
            handleOpen(key, keyPath) {
                console.log(key, keyPath);
            },
            handleClose(key, keyPath) {
                console.log(key, keyPath);
            },
        },
        mounted: function() {
            let user = sessionStorage.getItem('user');
            if (user) {
                this.username = user;
            }
        },
    }
</script>

<style lang="scss" scope>
    .app {
        $solidBorder: 1px solid #eee;
        $sideCollapsedWidth: 20px;
        $sideExpandedWidth: 230px;
        position: absolute;
        font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
        font-size: 1em;
        height: 100%;
        min-width: 800px;
        width: 100%;


        .app-side-logo {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            // height: 59px;
            // line-height: 59px;
            text-align: center;
            position: relative;
            z-index: 1300;
            background: rgb(84, 92, 100);
            transition: all 0.3s ease-in-out;
            border-bottom: 1px solid #313d4f;
            cursor: pointer;

            .logo {
                max-width: 70%;
                max-height: 90%;
                vertical-align: middle;
            }
        }

        .app-side {
            overflow-x: hidden
        }

        .app-side-logo1 {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 59px;
            line-height: 59px;
            text-align: center;
            position: relative;
            z-index: 1300;
            background: rgb(84, 92, 100);
            transition: all 0.3s ease-in-out;
            border-bottom: 1px solid #313d4f;

            .logo {
                max-width: 70%;
                max-height: 90%;
                vertical-align: middle;
            }
        }

        .headlogo {
            max-width: 70%;
            max-height: 90%;
            vertical-align: middle;
        }

        .headlogo1 {
            max-width: 70%;
            max-height: 90%;
            vertical-align: middle;
        }

        &-side {
            // width: 160px;
            // font-weight: 200;
            // border-right: $solidBorder;



            &-left {
                background-color: rgb(238, 241, 246);
            }

            &-logo {
                // height: 60px;
                // width: 211px;
                text-align: center;
                position: fixed;
                z-index: 99;
                background-color: rgb(84, 92, 100);

            }

            &-logo1 {
                height: 60px;
                width: 47px;
                text-align: center;
                position: fixed;
                z-index: 99;
                background-color: rgb(84, 92, 100);

            }

            &-collapsed {
                width: 50px !important;
            }

            &-expanded {
                width: 230px !important;
            }
        }

        &-header {
            width: 100%;
            height: 60px;
            display: flex;
            flex-flow: row nowrap;
            justify-content: flex-start;
            align-items: center;
            border-bottom: $solidBorder;

            &-userinfo {
                position: absolute;
                right: 0;
                margin-right: 25px;
                display: flex;
                flex-flow: row nowrap;
                height: 60px;
                justify-content: flex-start;
                align-items: center;
            }
        }
    }

    .app-header-userinfo {
        position: absolute;
        right: 10px;
        cursor: pointer;

        .userShow {
            transition: all 0.3s ease-in-out;
            cursor: pointer;
            height: 40px;
            line-height: 40px;
            width: 40px;
            border-radius: 20px;
            display: flex;
            align-items: center;
            color: #999999;
            float: left;

            img {
                width: 36px;
                height: 36px;
                vertical-align: middle;
                border-radius: 50%;
                box-sizing: border-box;
                overflow: hidden;
            }
        }
    }

    .inline-block {
        display: inline-block;
    }

    .quitStyle {
        display: inline-block;
        width: 24px;
        height: 24px;
    }

    .el-menu-item.is-active {
        background-color: #FAAD14 !important;
    }

    .container {
        position: relative;
        height: 100%;
        overflow-y: auto;
        width: 100%;
        overflow-x: hidden;
    }
</style>